home *** CD-ROM | disk | FTP | other *** search
- /*--------------------------------------------------------------------------*/
- /* The Opus Computer-Based Conversation System */
- /* (c) Copyright 1987, Wynn Wagner III, All Rights Reserved */
- /* */
- /* YOOHOO is a trademark of Wynn Wagner III */
- /* */
- /* YOOHOO-YOOHOO/2U2 is */
- /* Copyright 1987, Wynn Wagner III, All Rights Reserved */
- /* */
- /* */
- /* BinkleyTerm "SendWaZOO" Processor */
- /* */
- /* */
- /* This module is a very simple FOSSIL-based terminal emulator. It is */
- /* provided for your information only. You will find routines that need */
- /* to be coded and identifiers to be resolved. It has been previously */
- /* known as "OpusLink" and "OConnect". The use of the name "BinkleyTerm" */
- /* does not preclude the possibility that another "OpusLink" or "OConnect" */
- /* could be released. */
- /* */
- /* There is absolutely no guarantee that anything here will work. If you */
- /* break this routine, you own both pieces. */
- /* */
- /* USAGE: You may use this material in any program with no obligation */
- /* as long as there is no charge for your program. For more */
- /* information about commercial use, contact the "OPUSinfo HERE" */
- /* BBS (124/111). */
- /* */
- /* */
- /*--------------------------------------------------------------------------*/
-
- #include <signal.h>
- #include <ctype.h>
- #include <conio.h>
-
- #define WAZOO_SECTION
- #include "zmodem.h"
-
- #include "com.h"
- #define rb_plus "r+b"
-
- extern char *BUNDLE_msg;
- extern char *FIND_msg;
- extern int n_requests;
- extern int caller;
- extern int sent_mail;
- extern int called_net, called_node;
-
- extern int (*wzgetfunc)(), (*wzsendfunc)();
-
- char *request_template = "%s%04x%04x.REQ";
-
- char *ext_flags = "ODCH"; /* Change to whatever, and */
- #define NUM_FLAGS 4 /* bump this, to add flags */
-
- int net_problems; /* This should be external */
-
- /*--------------------------------------------------------------------------*/
- /* SEND WaZOO (send another WaZOO-capable Opus its mail) */
- /* returns TRUE (1) for good xfer, FALSE (0) for bad */
- /* use instead of n_bundle and n_attach for WaZOO Opera */
- /*--------------------------------------------------------------------------*/
- int pascal send_WaZOO()
- begin
- FILE *fp;
- char fname[80];
- char s[80];
- char *sptr;
- char *password;
- int c;
- int i;
- int fsent;
- struct stat buf;
-
- long current, last_start;
-
-
- fsent = 0;
-
-
- /*--------------------------------------------------------------------*/
- /* Send all waiting ?UT files (mail bundles) */
- /*--------------------------------------------------------------------*/
- *ext_flags = 'O';
- for(c=0; c<NUM_FLAGS; c++)
- begin
- if (caller && (ext_flags[c] == 'H'))
- continue;
-
- sprintf( fname,
- "%s%04x%04x.%cUT",
- ctl.hold_area,called_net,called_node,ext_flags[c]);
- errno = 0;
-
- if (!stat(fname,&buf))
- begin
-
- /*--- Build a dummy PKT file name */
- invent_pkt_name(s);
-
- /*--- Tell ZModem to handle this as a SEND AS then DELETE */
- status_line(BUNDLE_msg);
-
- if (!(*wzsendfunc)(fname,s,DELETE_AFTER,fsent++,DO_WAZOO))
- begin
- net_problems = 1;
- return FALSE;
- end
-
- /* if ( (locate_y) and (locate_y!=0xffff) )
- gotoxy( 0, (byte )locate_y-1 );*/
-
- end
-
- end /* for */
-
-
- /*--------------------------------------------------------------------*/
- /* Send files listed in ?LO files (attached files) */
- /*--------------------------------------------------------------------*/
- *ext_flags = 'F';
- for(c=0; c<NUM_FLAGS; c++)
- begin
- if (caller && (ext_flags[c] == 'H'))
- continue;
-
- sprintf( fname, "%s%04x%04x.%cLO",
- ctl.hold_area,called_net,called_node,ext_flags[c]);
- errno = 0;
-
- if (!stat(fname,&buf))
- begin
-
-
- errno = 0;
- fp = fopen( fname, rb_plus );
- if (got_error(OPEN_msg,fname))
- begin
- continue;
- end
-
- current = 0L;
- while(!feof(fp))
- begin
- s[0] = 0;
- last_start = current;
- fgets(s,79,fp);
- if (got_error(READ_msg,fname)) s[0] = 0;
-
- sptr = s;
- password = NULL;
-
- for(i=0; sptr[i]; i++)
- if (sptr[i]=='!') password = sptr+i+1;
-
- if (password)
- begin
- password = sptr+i+1;
- for(i=0; password[i]; i++)
- if (password[i]<=' ') password[i]=0;
- fancy_str(password);
- if (strcmp(password,remote_password))
- begin
- status_line("!RemotePwdErr %s %s",password,remote_password);
- continue;
- end
- end
-
- for(i=0; sptr[i]; i++)
- if (sptr[i]<=' ') sptr[i]=0;
-
- current = ftell(fp);
-
- if (sptr[0]=='#')
- begin
- sptr++;
- i = TRUNC_AFTER;
- end
- else i = NOTHING_AFTER;
-
- if (!sptr[0])
- begin
- continue;
- end
-
-
- if (sptr[0] != '~')
- begin
-
- if (stat(sptr,&buf)) /* file exist? */
- begin
- got_error(FIND_msg,sptr);
- continue;
- end
- else if (!buf.st_size)
- begin
- continue; /* 0 length? */
- end
-
- if (!(*wzsendfunc)(sptr,NULL,i,fsent++,DO_WAZOO))
- begin
- fclose(fp);
- net_problems = 1;
- return FALSE;
- end
-
- /*--------------------------------------------*/
- /* File was sent. Flag file name */
- /*--------------------------------------------*/
- /* if ( (locate_y) and (locate_y!=0xffff) )
- gotoxy( 0, (byte )locate_y-1 );*/
-
- fseek( fp, last_start, SEEK_SET );
- putc('~',fp); /* flag it */
- fflush (fp);
- rewind(fp); /* clear any eof flags */
- fseek( fp, current, SEEK_SET );
- errno = 0;
-
- end
-
- end /* while */
-
- errno = 0;
- fclose(fp);
- got_error(CLOSE_msg,fname);
- unlink(fname);
- errno = 0;
-
- end /* !stat */
-
- end /* for */
-
- /*--------------------------------------------------------------------*/
- /* Send our File requests to other system */
- /*--------------------------------------------------------------------*/
- sprintf( fname, request_template, ctl.hold_area, called_net, called_node );
- if (!stat(fname,&buf))
- begin
-
- if (!(remote_capabilities&WZ_FREQ)) status_line("*F.REQ. declined");
- else
- begin
- status_line("*Making file request");
- if ((*wzsendfunc)(fname,NULL,NOTHING_AFTER,fsent++,DO_WAZOO))
- unlink(fname);
- end
-
- end
-
-
-
- fsent = respond_to_file_requests(fsent);
-
- errno = 0;
- if (!fsent) status_line("+Nothing to send from %d/%d to %d/%d",
- ctl.alias[0].net, ctl.alias[0].node,
- called_net, called_node );
-
- (*wzsendfunc)(NULL,NULL,NOTHING_AFTER,((fsent)?END_BATCH:NOTHING_TO_DO),DO_WAZOO);
-
- sent_mail = 1;
-
- return TRUE;
-
- end /* WaZOO */
-
-
-
-
-
-
- /*--------------------------------------------------------------------------*/
- /* RESPOND TO FILE REQUEST */
- /*--------------------------------------------------------------------------*/
- int respond_to_file_requests(fsent)
- int fsent;
- begin
-
- static char req[80];
- extern char *n_frproc();
- struct stat buf;
- FILE *fp;
- int i;
- int np;
- int junk;
- int nfiles;
- byte *rqname;
-
-
- if (!(ctl.matrix_mask&TAKE_REQ)) goto done;
-
- for (np = 0; np <= 10; np++)
- begin
- if (ctl.alias[np].net == 0)
- break;
-
- sprintf(req,request_template,ctl.filepath,
- ctl.alias[np].net,ctl.alias[np].node);
-
- if (!stat(req,&buf))
- begin
- errno = 0;
- fp = fopen(req,read_ascii);
- if (got_error(OPEN_msg,req)) goto done;
- nfiles = 0;
- while(!feof(fp))
- begin
- req[0] = 0;
- if (fgets(req,79,fp) == NULL)
- break;
-
- /* ; as the first char is a comment */
- if (req[0] == ';')
- continue;
-
- junk = -1;
- do
- begin
- if ((rqname = n_frproc(req, &junk, 0)) != NULL)
- if (!(*wzsendfunc)(rqname,NULL,NOTHING_AFTER,fsent++,DO_WAZOO))
- goto done;
- ++nfiles;
- if (nfiles > n_requests)
- begin
- status_line ("!File Request limit exceeded");
- junk = -1;
- end
- end
- while (CARRIER && (junk >= 0));
- end
-
- sprintf(req,request_template,ctl.filepath,
- ctl.alias[np].net,ctl.alias[np].node);
- errno = 0;
- fclose(fp);
- got_error(CLOSE_msg,req);
-
- /* Note that Opus does not delete this file, but we should I think */
- unlink(req);
- got_error(UNLINK_msg,req);
- /* once we have satisfied a request, we can get out of here */
- break;
- end
- end
-
- done:
- return fsent;
-
- end